/*
 *2020年11月5日
 *@author:huhu
 */
public class Producer implements Runnable{
    private  Staging_Area storage;
    int id;
    public Producer(){

    }
    public Producer(Staging_Area storage){
        this.storage = storage;
    }
    public Producer(Staging_Area storage,int id){
        this.storage = storage;
        this.id = id;
    }
    public int getId() {
        return id;
    }
    public void run(){
        int n=0;
        while (n<Test.max) {
            try {
                Thread.sleep(Test.produceSpeed);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //根据生产者id进行生产操作 n%Test.producerCount完成循环顺序生产
            storage.produce(Test.producerLinkedList.get(n%Test.producerCount).getId());
            n++;
        }
    }
}